<?php 
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];

$url = "http://localhost:8080/moms-diary/services/timeline";

$auth = $username.":".$password;

$context = stream_context_create(array(
    'http' => array(
        'header'  => "Authorization: Basic " . base64_encode($auth)
	)
));
$data = file_get_contents($url, false, $context);
if(isset($data)) {
	//echo $data;	
	$json = json_decode($data);
	
	for ($i=0;$i <= strlen($data) ; $i++)
  	{
		$media = "img.php?q=".$json->timeline->date[$i]->asset->media;
  		$json->timeline->date[$i]->asset->media = $media;
  	}
	

	echo json_encode($json);
//	echo $json;
}
